#include <stdio.h>
#include <string.h>
#include "fun/fun.h"
#include "sup/sup.h"
char *gets_Data(char *datas);
int MAX_course=0; //最大课程数
int MAX_pupil=0; //最大学生数
struct pupil *_pupils_arr[1000];
struct course *_courses_arr[1000];//add comment
int main(){
    char data[1024];
    FILE *fp;
    char *buf[200];
    char *buf2;
    int i=0;
    int pupils_count_=0;
    int courses_count_=0;
    int now_cour_or_pup=3;//0 is courses 1 is pupils   //now is 3 because first one
    if((fp=fopen("huzhen.txt","r"))==NULL)
    {
        printf("File Name Error.\n");
        return 0;
    }
    while(fgets(data,1024,fp)){
        //printf("%s",data);

        if(now_cour_or_pup==0&&str_cmp(data,"--pupils--")!=0) {// the last is one
            init(1,0);
            (_courses_arr[MAX_course])->name=gets_Data(data);
            MAX_course++;
        }


        if(now_cour_or_pup==1&&str_cmp(data,"--end--")!=0){// the last is one
            init(0,1);
            (_pupils_arr[MAX_pupil])->name=gets_Data(data);
            MAX_pupil++;
        }
        if(str_cmp(data,"--courses--")==0){
            now_cour_or_pup=0;
        }
        if(str_cmp(data,"--pupils--")==0){
            now_cour_or_pup=1;
        }
    }
    printf("MAX_course is %d\tMAX_pupil is %d\n",MAX_course,MAX_pupil);
//    for(i=0;i<5;i++){
//       printf("%s%s",(_courses_arr[i])->name,(_pupils_arr[i])->name);
//    }
    xuanke("english","huzhen");
    xuanke("db","huzhen");
    xuanke("os","huzhen");
    xuanke("english","liufan");
    xuanke("db","liufan");
    xuanke("os","liufan");
xuanke("os","liufan");
    //printf("now is xuanke hou\n");
    //lookall();
    printf("now is tuike hou\n");
    tuike("english","huzhen");
    lookall("huzhen");
    xiugai("os","english","huzhen");
    printf("now is xiugai hou\n");
    lookall();
    lookpupil("huzhen");
    lookcouse("english");

}

